﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
//using System.Linq;
using System.Text;
using System.Windows.Forms;

using System.Collections;// ArrayList用

namespace Xuhengxiao.MediaConverter
{
    public partial class UserControlComboBox : UserControl
    {
        //这个用户控件有一个 lable 控件，有一个ComboBox 控件，
        //有几个属性，

        //数据名称
        public string DataName
        {
            get { return lblDataName.Text; }
            set { lblDataName.Text = value; }
        }

        //下拉列表框项目
        public ComboBox.ObjectCollection Items
        {
            get { return comboData.Items; }
        }

        //取得选中值
        public string Text
        {
            get { return comboData.Text; }
            set { comboData.Text = value; }
        }

        //下拉框类型
        public ComboBoxStyle DropDownStyle
        {
            get { return comboData.DropDownStyle; }
            set { comboData.DropDownStyle = value; }

        }

        //下拉框是否以字母顺序排序
        public bool Sorted
        {
            get { return comboData.Sorted; }
            set { comboData.Sorted = value; }
        }

        public UserControlComboBox()
        {
            InitializeComponent();
        }

        public void BuJu()
        {
            lblDataName.Location = new Point(3, 4);//这个是不变的
            comboData.Location = new Point((lblDataName.Location.X + lblDataName.Width), 1);//加上那个lable控件的宽度，
            comboData.Width = this.Width - comboData.Location.X - 5;//
        }

        private void UserControlComboBox_Resize(object sender, EventArgs e)
        {
            BuJu();
        }

        private void lblDataName_Resize(object sender, EventArgs e)
        {
            BuJu();
        }

        //清空数据
        public void clearComboData()
        {
            comboData.Items.Clear();
        }
    }
}
